package com.leader.say.controller;

import com.leader.say.dao.LeaderMapper;
import com.leader.say.entity.LeaderSay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author admin
 */
@Controller
public class LeaderSayController {

    @Autowired
    LeaderMapper leaderMapper;

    @RequestMapping("/")
    public String leader(Map<String, Object> map) {
        List<LeaderSay> leaderSays = leaderMapper.selectAllSay();
        map.put("leaderSays", leaderSays);
        return "leader";
    }

    @RequestMapping("/insertLeaderSay")
    @ResponseBody
    public Object insertLeaderSay(String msg) {
        try {
            leaderMapper.insertLeaderSay(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        List<LeaderSay> leaderSays = leaderMapper.selectAllSay();
        return leaderSays;
    }
}
